package cn.botter.subject.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @BelongsProject: bo-club
 * @BelongsPackage: cn.botter.subject.domain.config
 * @Author: 爱写Bug的Botter
 * @CreateTime: 2025-03-28:18:53
 * @Description: 描述
 * @Version: 1.0
 */
@Configuration
public class ThreadPoolConfig {
    @Bean
    public ThreadPoolExecutor getLabelThreadPool(){
        return new ThreadPoolExecutor(20, //线程池中的最大核心线程数
                100, //线程中能拥有的最大线程数
                5,  //
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(40), //用于缓存任务的阻塞队列
                new DivThreadFactory("label"),
                new ThreadPoolExecutor.CallerRunsPolicy());   //当阻塞队列满了的时候，执行的拒绝策略，这里定义默认的友好拒接策略，尽量不要选择带有抛异常的拒绝策略
    }
}
